{php include wl_template('common/header');}
<style>
    label{font-weight:400;}
</style>
<ul class="nav nav-tabs" id="myTab">
    <li class="active"><a href="#tab_basic">基本信息</a></li>
    <li><a href="#tab_detail">项目详情</a></li>
<!--<li><a href="#tab_appoint">预约设置</a></li>-->
    <li><a href="#tab_share">分享设置</a></li>
</ul>
<div class="app-content">
    <div class="app-form">
        <form action="" method="post" class="form-horizontal form form-validate">
            <div class="tab-content">
                <div class="tab-pane active" id="tab_basic">
                    <div class="form-group-title">基本信息</div>
                    {if !is_store()}
                    <div class="form-group">
                        <label class="col-sm-2 control-label"><span class="form-must">*</span>服务者类型</label>
                        <div class="col-sm-9">
                            <label class="radio-inline" onclick="$('#serstore').show();$('#artificer').hide();" >
                                <input type="radio" name="service[type]" value="1" {if empty($service['type']) || $service['type'] == 1}checked{/if}> 商户发布
                            </label>
                            <label class="radio-inline" onclick="$('#serstore').hide();$('#artificer').show();">
                                <input type="radio" name="service[type]" value="2" {if $service['type'] == 2} checked{/if}> 个人发布
                            </label>
                        </div>
                    </div>
                    <div class="form-group" id="serstore"  {if $service['type'] == 2} style="display: none;" {/if}>
                        <label class="col-sm-2 control-label"><span class="form-must">*</span>服务商户</label>
                        <div class="col-sm-7 col-xs-6">
                            <select name="service[sobjid]" class="form-control select2 col-sm-7 col-xs-6" style="width: 100%;">
                                {loop $stores $sto}
                                <option value="{$sto['id']}" {if $sto['id'] == $service['objid']} selected="selected" {/if}>{$sto['storename']}</option>
                                {/loop}
                            </select>
                        </div>
                    </div>
                    <div class="form-group" id="artificer"  {if $service['type'] == 1 || empty($service) } style="display: none;" {/if}>
                        <label class="col-sm-2 control-label"><span class="form-must">*</span>服务者</label>
                        <div class="col-sm-7 col-xs-6">
                            <select name="service[aobjid]" class="form-control select2 col-sm-7 col-xs-6" style="width: 100%;">
                                {loop $artificers $art}
                                <option value="{$art['id']}" {if $art['id'] == $service['objid']} selected="selected" {/if}>{$art['name']}</option>
                                {/loop}
                            </select>
                        </div>
                    </div>
                    {/if}
                    <div class="form-group">
                        <label class="col-sm-2 control-label"><span class="form-must">*</span>服务标题</label>
                        <div class="col-sm-9">
                            <input type="text" name="service[title]" maxlength="16" class="form-control" value="{$service['title']}" placeholder="请输入服务标题" required>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label"><span class="form-must">*</span>服务类目</label>
                        <div class="col-sm-9">
                            <select name="category[]" class="form-control select2" multiple>
                                {loop $categoryes $parent}
                                <optgroup label="{$parent['title']}">
                                    {loop $parent['list'] $children}
                                    <option value="{$children['id']}" {if in_array($children['id'], $cateids)}selected{/if}>{$children['title']}</option>
                                    {/loop}
                                </optgroup>
                                {/loop}
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label"><span class="form-must">*</span>支付金额类型</label>
                        <div class="col-sm-9">
                            <label class="radio-inline" onclick="$('#pricediv').hide();" >
                                <input type="radio" name="service[pricetype]" value="0" {if empty($service['pricetype']) || $service['pricetype'] == 0}checked{/if}> 面议
                            </label>
                            <label class="radio-inline" onclick="$('#pricediv').show();" >
                                <input type="radio" name="service[pricetype]" value="1" {if $service['pricetype'] == 1} checked{/if}> 订金
                            </label>
                            <label class="radio-inline" onclick="$('#pricediv').show();" >
                                <input type="radio" name="service[pricetype]" value="2" {if $service['pricetype'] == 2} checked{/if}> 实价
                            </label>
                            <span class="help-block">面议：下单时不需要支付任何金额，服务人员上门后面议金额；订金：用户下单时预先支付订金，服务人员上门后支付尾款；实价：用户下单时支付所有金额，后续不需要在支付金额。</span>
                        </div>
                    </div>
                    <div id="pricediv" class="form-group" {if $service['pricetype'] == 0 || empty($service)} style="display: none;" {/if}  >
                        <label class="col-sm-2 control-label"><span class="form-must">*</span>支付金额</label>
                        <div class="col-sm-9">
                            <div class="input-group">
                                <span class="input-group-addon">金额￥</span>
                                <input type="number" name="service[price]" class="form-control" min="0" value="{$service['price']}" />
                                <span class="input-group-addon">单位</span>
                                <input type="text" name="service[unit]" class="form-control" value="{$service['unit']}" />
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label"><span class="form-must">*</span>缩略图</label>
                        <div class="col-sm-9">
                            {php echo attachment_select('service[thumb]', $service['thumb'])}
                            <span class="help-block">服务项目缩略图，建议使用正方形图片</span>
                        </div>
                    </div>
                    {if !is_store()}
                    <div class="form-group">
                        <label class="col-sm-2 control-label">列表排序</label>
                        <div class="col-sm-9">
                            <input type="number" name="service[sort]" maxlength="16" class="form-control" value="{$service['sort']}" placeholder="排序数字，数字越大越靠前">
                        </div>
                    </div>
                    {/if}
                    <div class="form-group">
                        <label class="col-sm-2 control-label">服务状态</label>
                        <div class="col-sm-9">
                            <label class="radio-inline">
                                <input type="radio" name="service[status]" value="1" {if $service['status'] == 1}checked{/if}> 销售中
                            </label>
                            <label class="radio-inline">
                                <input type="radio" name="service[status]" value="0" {if empty($service['status'])} checked{/if}> 已下架
                            </label>
                            {if !is_store()}
                            {if $service['status'] == 4}
                            <label class="radio-inline">
                                <input type="radio" name="service[status]" value="4" {if $service['status'] == 4} checked{/if}> 被删除
                            </label>
                            {/if}
                            {if $service['status'] == 5}
                            <label class="radio-inline">
                                <input type="radio" name="service[status]" value="5" {if $service['status'] == 5} checked{/if}> 待审核
                            </label>
                            {/if}
                            {if $service['status'] == 6}
                            <label class="radio-inline">
                                <input type="radio" name="service[status]" value="6" {if $service['status'] == 6} checked{/if}> 被驳回
                            </label>
                            {/if}
                            {/if}
                        </div>
                    </div>
                </div>
                <div class="tab-pane" id="tab_detail">
                    <div class="form-group-title">项目详情</div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">案例照片</label>
                        <div class="col-sm-9">
                            {php echo attachment_select_multi('service[adv]',$service['adv']);}
                            <span class="help-block">显示在服务详情页面顶部的幻灯片。</span>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">视频链接</label>
                        <div class="col-sm-9">
                            <div class="input-group">
                                <input type="text" value="{$service['videourl']}" name="service[videourl]" class="form-control" autocomplete="off" id="cimg-videourl">
                                <span class="input-group-btn">
                                    <button class="btn btn-default" type="button" data-toggle="selectVideo" data-input="#cimg-videourl" data-img="#pimg-videourl" >选择媒体文件</button>
                                </span>
                            </div>
                            <span class="help-block">显示在服务详情页面顶部的视频。</span>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">虚拟销量</label>
                        <div class="col-sm-9">
                            <input type="number" name="service[salenum]" min="0"  maxlength="10" class="form-control" value="{$service['salenum']}" placeholder="请输入虚拟销量">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">详情介绍</label>
                        <div class="col-sm-9">
                            {php echo tpl_diy_editor_create('service[detail]', $service['detail']);}
                        </div>
                    </div>
                </div>
                <div class="tab-pane" id="tab_appoint">
                    <div class="form-group-title">预约设置</div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">预约功能</label>
                        <div class="col-sm-9">
                            <label class="radio-inline" onclick="$('#appointdiv').show();">
                                <input type="radio" value="1"  name="service[appointstatus]" {if $service['appointstatus']==1} checked {/if}> 开启
                            </label>
                            <label class="radio-inline" onclick="$('#appointdiv').hide();">
                                <input type="radio" value="0"  name="service[appointstatus]" {if $service['appointstatus']==0 || empty($service['appointstatus'])} checked {/if}>关闭
                            </label>
                            <span class="help-block">开启预约后,下单时需要提前选择预约时间。</span>
                        </div>
                    </div>
                    <div id="appointdiv" {if $service['appointstatus']==0 || empty($service['appointstatus'])} style="display:none;"  {/if} >
                        <div class="form-group">
                            <label class="col-sm-2 control-label">预约小时</label>
                            <div class="col-sm-9">
                                <div class="input-group">
                                    <span class="input-group-addon">请于</span>
                                    <input type="number" name="service[appointment]" min="0" class="form-control" value="{$service['appointment']}" />
                                    <span class="input-group-addon">小时前预约</span>
                                </div>
                                <span class="help-block">不填或填0即可立即预约。</span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">最近预约天数</label>
                            <div class="col-sm-9">
                                <div class="input-group">
                                    <span class="input-group-addon">最近可预约</span>
                                    <input type="number" name="service[appointdays]" min="0" class="form-control" value="{$service['appointdays']}" />
                                    <span class="input-group-addon">天</span>
                                </div>
                                <span class="help-block">不填或填0即最多可以预约30天;如果填1，只能预约当天与明天的位置，填2即可预约当天,明天和后天的位置，以此类推。</span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">每日预约详情</label>
                            <div class="col-sm-9" id="appointarray">
                                {if !empty($service['appointarray'])}
                                {loop $service['appointarray'] $appli}
                                {php include wl_template('goodshouse/appointhtml');}
                                {/loop}
                                {/if}
                            </div>
                            <div class="form-group sms-template-1" style="display:block;">
                                <label class="col-sm-2 control-label"></label>
                                <div class="col-sm-9">
                                    <a class="btn btn-default btn-add-type" href="javascript:;" onclick="addAppoint();">
                                        <i class="fa fa-plus" title=""></i>增加一个时间段
                                    </a>
                                    <span class="help-block">接待人数填0或者不填即代表不限人数。</span>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="tab-pane" id="tab_share">
                    <div class="panel panel-default">
                        <div class="panel-body">
                        <div class="form-group-title">分享设置</div>
                            <div class="alert alert-info">
                                <b>适用模板变量：[昵称] [时间] [项目名称] [价格] </b>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">公众号分享图片</label>
                                <div class="col-sm-9">
                                    {php echo attachment_select('service[share_image]', $service['share_image']);}
                                    <span class="help-block">大小2M以下，建议尺寸500*500，如果不选择，默认为商品缩略图片</span>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">小程序分享图片</label>
                                <div class="col-sm-9">
                                    {php echo attachment_select('service[share_wxapp_image]', $service['share_wxapp_image']);}
                                    <span class="help-block">大小2M以下，建议尺寸500*400，如果不选择，默认为商品缩略图片</span>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">分享标题</label>
                                <div class="col-sm-9">
                                    <input type="text" name="service[share_title]" class="form-control" value="{$service['share_title']}" />
                                    <span class="help-block">如果不填写，默认为商品名称</span>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">分享描述</label>
                                <div class="col-sm-9">
                                    <input type="text" name="service[share_desc]" class="form-control" value="{$service['share_desc']}" />
                                    <span class="help-block">如果不填写，默认为分享描述</span>
                                </div>
                            </div>
                            {if p('diyposter')}
                            <div class="form-group">
                                <label class="col-sm-2 control-label">自定义海报</label>
                                <div class="col-sm-9">
                                    <select name="service[diyposter]" class="form-control">
                                        <option value="0">默认海报</option>
                                        {loop $posters $poster}
                                        <option value="{$poster['id']}" {if $service['diyposter'] == $poster['id']}selected="selected"{/if}>{$poster['title']}</option>
                                        {/loop}
                                    </select>
                                </div>
                            </div>
                            {/if}
                        </div>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label"></label>
                <div class="col-sm-9">
                    <input type="submit" name="submit" value="提交" class="btn btn-primary min-width" />
                    <input type="hidden" name="token" value="{$_W['token']}" />
                    <input type="hidden" name="id" value="{$service['id']}" />
                </div>
            </div>
        </form>
    </div>
</div>
<script>
    $(function () {
        window.optionchanged = false;
        $('#myTab a').click(function (e) {
            e.preventDefault();//阻止a链接的跳转行为
            $(this).tab('show');//显示当前选中的链接及关联的content
        });
    });

    var kw = 0;
    function addAppoint() {
        $(".btn-add-type").html("loading.....");
        $.ajax({
            url: "{php echo web_url('goodshouse/goodshouse/appointarray')}&house=1&kw="+kw,
            cache: false
        }).done(function (html) {
            var rest = '<i class="fa fa-plus" title=""></i>增加一个时间段';
            $(".btn-add-type").html(rest);
            $("#appointarray").append(html);
        });
        kw++;
    }
    $(document).on('click', '.data-item-delete', function () {
        $(this).closest('.data-item').remove();
    });

</script>
{php include wl_template('common/footer');}
